import { defineStore } from 'pinia'

export const authStore = defineStore('authorizationStore', () => {

	const username = useCookie('username');
	const fio_short = useCookie('fio_short');
	const dolzh = useCookie('dolzh');
	const groups = useCookie('groups');

	async function cookieReset() {
		username.value = "";
		fio_short.value = "";
		dolzh.value = "";
		groups.value = "";
	}

	async function setAuth(username, fio_short, dolzh, groups) {
		await cookieReset();
		username.value = username
		fio_short.value = fio_short
		dolzh.value = dolzh
		groups.value = groups
		console.log("test")
	}

	return { username, fio_short, dolzh, groups, setAuth, cookieReset }
})